package com.shkmall.system.service.imp;

import com.shkmall.system.dao.AdminMapper;
import com.shkmall.system.pojo.Admin;
import com.shkmall.system.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;
    @Override
    @Transactional
    public void add(Admin admin) {
        /*获取盐*/
        String gensalt = BCrypt.gensalt();
        String hashpw = BCrypt.hashpw(admin.getPassword(), gensalt);
        admin.setPassword(hashpw);
        admin.setStatus("1");
        adminMapper.insert(admin);
    }
}
